import os.path
import time

from global_variables import GlobalVariables

HISTORY_FILE_PATH = GlobalVariables.PROJECT_BASE_PATH + 'history'


def read():
    if not os.path.isfile(HISTORY_FILE_PATH):
        return ''

    with open(HISTORY_FILE_PATH, 'r') as f:
        result = f.read()
        return result


def write(sql: str):
    sql = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "  " + sql
    with open(HISTORY_FILE_PATH, 'a') as f:
        f.write(sql + os.linesep)


if __name__ == '__main__':
    pass
